<?php


namespace app\admin\controller\setting;

use app\admin\controller\AdminController;
use app\admin\service\setting\PayService;
use app\admin\validate\setting\PayValidate;
use think\response\Json;

class Pay extends AdminController
{

    /**
     * 获取短信配置列表
     * @return Json
     */
    public function lists()
    {
        return $this->success(PayService::lists());
    }


    /**
     * 短信配置信息
     * @return Json
     */
    public function detail()
    {
        $param = (new PayValidate())->checkParam('detail');
        return $this->success(PayService::detail($param));
    }


    /**
     * 设置短信配置
     * @return Json
     */
    public function edit()
    {
        $params = (new PayValidate())->post()->checkParam('edit');
        $result = PayService::edit($params);
        if (true === $result) {
            return $this->success([], '配置成功');
        } else {
            return $this->error(PayService::getError());
        }
    }


    /**
     * 切换短信驱动
     * @return Json
     */
    public function change()
    {
        $params = $this->postData();
        $result = PayService::change($params);
        if (true === $result) {
            return $this->success([], '切换成功');
        } else {
            return $this->error(PayService::getError());
        }
    }
}